<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model backend\modules\api\models\ApiRoleUser */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="api-role-user-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'user_id')->widget(\kartik\select2\Select2::className(),[
        'data'=>\yii\helpers\ArrayHelper::map(\common\models\User::find()->asArray()->all(),'id', 'username'),
    ])->label('用户名') ?>

    <?= $form->field($model, 'api_role_id')->widget(\kartik\select2\Select2::className(),[
        'data'=>\yii\helpers\ArrayHelper::map(\common\models\ApiRole::find()->asArray()->all(),'id', 'name'),
    ])->label('角色名') ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '新建' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
